<?php

namespace backend\utils;

use Yii;
use yii\helpers\Url;

class RememberUrl
{
    private $url = '';
    private $name = '';

    const SCHOOL_MAJOR_LIST = 'school_major_list';
    const PROVINCE_LIST = 'province_list';
    const PROVINCE_VIEW = 'province_view';
    const JYB_VIEW = 'jyb_view';

    const PROV_PREVIEW = 'prov_view';


    const BACK_URL = 'back_url';
    const PROV_BACK_URL = 'prov_back_url';

    const VIEW_WEB_BACK = 'view_web_back';// 查看申报书页面返回按钮

    const REVIEW_SCORE_BACK = 'REVIEW_SCORE_BACK';// 审核打分页面


    public static function init($name, $url = "")
    {
        $obj = new self();
        $obj->name = $name;
        $obj->url = $url;

        return $obj;
    }

    /**
     * set url
     * https://www.yiiframework.com/doc/guide/2.0/zh-cn/helper-url
     *
     * @time 2020-07-09 PM
     */
    public function set_url()
    {
        if (!$this->url) {
            $this->url = Yii::$app->request->url;
        }
        Url::remember($this->url, $this->name);
    }

    /**
     * 获取url
     *
     * @time 2020-07-09 PM
     */
    public function get_url()
    {
        return Url::previous($this->name);
    }


}
